package com.example.pt.enums;


public enum PromotionType {
    FREE(0, "免费下载", 0.0),
    DISCOUNT_50(1, "50%折扣", 0.5),
    DISCOUNT_30(2, "30%折扣", 0.7);

    private final int value;
    private final String name;
    private final double discountRate;

    PromotionType(int value, String name, double discountRate) {
        this.value = value;
        this.name = name;
        this.discountRate = discountRate;
    }

    public int getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    public double getDiscountRate() {
        return discountRate;
    }

    // 根据值获取枚举
    public static PromotionType fromValue(int value) {
        for (PromotionType type : PromotionType.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的促销类型值: " + value);
    }
}